package com.dci.service.impl.project;

import com.dci.dao.pms.management.ProjectManageInfoMapper;
import com.dci.dao.pms.project.ProjectInfoMapper;
import com.dci.model.management.ProjectManageInfo;
import com.dci.model.project.ProjectInfo;
import com.dci.result.PageResult;
import com.dci.service.project.ProjectRecordService;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * All rights Reserved, Designed By 姑苏区政府大数据中心
 *
 * @version V1.0
 * @Title: null.java
 * @Package com.dci.service.impl.project
 * @Description: 项目查询实现类
 * @author: 张星亮
 * @date: 2019/2/25
 * @Copyright: 2019 姑苏区政府大数据中心. All rights reserved.
 * 注意：本内容仅限于姑苏区政府大数据中心内部传阅，禁止外泄以及用于其他的商业目
 */
@Service
public class ProjectRecordServiceImpl implements ProjectRecordService {

    @Resource
    private ProjectManageInfoMapper projectManageInfoMapper;

    @Resource
    private ProjectInfoMapper projectInfoMapper;

    @Override
    public PageResult selectAll(ProjectManageInfo projectManageInfo) {
        projectManageInfo.setPageNum(null);
        projectManageInfo.setPageSize(null);
        List<ProjectManageInfo> list = projectManageInfoMapper.selectAllByRecord(projectManageInfo);
        ProjectInfo projectInfo = new ProjectInfo();
        projectInfo.setName(projectManageInfo.getName());
        projectInfo.setConstructionUnit(projectManageInfo.getConstructionUnit());
        projectInfo.setStartTime(projectManageInfo.getStartTime());
        projectInfo.setEndTime(projectManageInfo.getEndTime());
        List<ProjectInfo> list1 = projectInfoMapper.selectByRecord(projectInfo);
        if (list1.size() > 0) {
            for (ProjectInfo projectInfo1 : list1) {
                ProjectManageInfo projectManageInfo1 = new ProjectManageInfo();
                projectManageInfo1.setId(projectInfo1.getId());
                projectManageInfo1.setName(projectInfo1.getName());
                projectManageInfo1.setType(3);
                projectManageInfo1.setHead(projectInfo1.getHead());
                projectManageInfo1.setHeadPhone(projectInfo1.getHeadPhone());
                projectManageInfo1.setContact(projectInfo1.getContact());
                projectManageInfo1.setContactPhone(projectInfo1.getContactPhone());
                projectManageInfo1.setConstructionUnit(projectInfo1.getConstructionUnit());
                projectManageInfo1.setImplementUnit(projectInfo1.getImplementUnit());
                projectManageInfo1.setImplementLimit(projectInfo1.getImplementLimit());
                projectManageInfo1.setMoneyInfo(projectInfo1.getMoneyInfo());
                projectManageInfo1.setDescription(projectInfo1.getDescription());
                projectManageInfo1.setDeclareTime(projectInfo1.getDeclareTime());
                projectManageInfo1.setOutboundStatus(projectInfo1.getOutboundStatus());
                projectManageInfo1.setAuditStatus(projectInfo1.getAuditStatus());
                projectManageInfo1.setApprovalStatus(projectInfo1.getApprovalStatus());
                projectManageInfo1.setApprovalType(projectInfo1.getApprovalType());
                projectManageInfo1.setProgressNumber(projectInfo1.getProgress_number());
                list.add(projectManageInfo1);
            }
        }
        PageInfo<ProjectManageInfo> pageInfo = new PageInfo<>(list);
        PageInfo<ProjectInfo> pageInfo1 = new PageInfo<>(list1);
        Long count = pageInfo.getTotal();
        return PageResult.success(list, null, null, count);
    }
}
